<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #box{
        width: 200px;
        height: 200px;
        background-color:black;
        margin: auto;
        color: #fff;
    }
</style>
<body>
    <div id="box" onmouseover="ys()" onmouseout="yc()">鼠标移入改变样式，鼠标移出恢复</div>
</body>
<script>
    function ys(){
        var x=document.getElementById('box').style.backgroundColor="red"
    }
    function yc(){
        var x=document.getElementById('box').style.backgroundColor="black"
    }
</script>
</html>